<?php
// 把wechat的openid等调用起来

namespace GMantuWeChat;

use GMantuWeChat\Common;

session_start();
//引入配置文件
include_once __DIR__.'/config.php';
//引入自动载入函数
include_once __DIR__.'/autoloader.php';
//调用自动载入函数
AutoLoader::register();


// 先获取用户的openid. 如果没有关注，也不强求，但是新弹出的页面加入生日的需要先关注. 
//var_dump($GLOBALS);
?>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>古曼图日历</title>
<meta name="description" content="古曼图日历，方便简洁日历的查询与提醒">
<meta name="Keywords" content="万年历,日历,日程,提醒,微信日历,阳历,阴历,公历,老皇历,假期,手机日历,公众号,方便" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<meta name="format-detection" content="telephone=no" />
<!--
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
-->
<link href="./resource/css/style.css" rel="stylesheet" type="text/css">
</head>

<body>
<header class="toolbar" id="toolbar">
	<span class="icon icon_calendar"></span>
	<h1></h1>
    <div class="action"><a href="#" class="today">回今天</a></div>
</header>

<div class="wrapper" id="wrapper">
	<div class="date_row date_week">
        <div class="date_item">周日</div>
        <div class="date_item">周一</div>
        <div class="date_item">周二</div>
        <div class="date_item">周三</div>
        <div class="date_item">周四</div>
        <div class="date_item">周五</div>
        <div class="date_item">周六</div>
    </div>
    
    <div class="slide_wrap">
    	<div class="date_slide"> 
            <div class="date_list" id="date_list_0">
            </div><!--date_list-->
            
            <div class="date_list" id="date_list_1">
            </div><!--date_list-->
        </div>
    </div>
    
    <div class="date_info">
        
        <div align="center" class="date_solar">
        <input type="button" click_prop="left_year" value="&nbsp;<<" class="button_left_right" /> 
        <input type="button" click_prop="left_month" value="&nbsp;<&nbsp;" class="button_left_right" />   
             <span id="date_solar_id" class="date_solar_date"> </span>
        <input type="button" click_prop="right_month" value="&nbsp;&nbsp;>" class="button_left_right" />
        <input type="button" click_prop="right_year" value="&nbsp;>>" class="button_left_right" />
        </div>
        
        <div class="date_fetv"></div>
        
        
        <div class="date_hl">
            <div class="date_gan_zhi"></div>
            
            <div class="date_hl_item">
                <div class="hl_y circle">宜</div>
                <span class="hl_y_content"></span>
            </div>
            
            <div class="date_hl_item">
                <div class="hl_j circle">忌</div>
                <span class="hl_j_content"></span>
            </div>
        </div>
    </div><!--date_info-->
</div>

<input type="hidden"  id="user_openid" name="user_openid" value="" />


<script type="text/javascript" src="./js/calendar/zepto.min.js"></script>
<script type="text/javascript" src="./js/calendar/hammer.min.js"></script>
<script type="text/javascript" src="./js/calendar/jquery.hammer.min.js"></script>
<script type="text/javascript" src="./js/calendar/LunarCalendar.js"></script>
<script type="text/javascript" src="./js/calendar/calendar.js"></script>


<?php

// 获取openid, 不需要获取userinfo. 根据openid就可以了. 
// 如果没有获取到，说明是非微信访问或者其他非正常分享途径过来的，不强求。不显示其自定义信息即可
if (isset($_GET['code']))
{
    $token = \GMantuWeChat\Common\WeChatOAuth::getAccessTokenAndOpenId($_GET['code']);
    // $ret = \GMantuWeChat\Common\WeChatOAuth::getUserInfo($token['access_token'], $token['openid']);

    $user_openid = $token['openid'];
    echo <<<EOT
        <script type="text/javascript">
        $("#user_openid").val("$user_openid");
        // alert("index html, userid=" + "$user_openid");
        </script>
EOT;
}

?>

</body>
</html> 